﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vds2465Telegrams;

namespace Vds2465Parser
{
	internal static class GenParse_UserData_02_StatusChangeReport2Confirm
	{
		#region private constants

		private const int NrOfBytes = 7;

		#endregion private constants

		#region internal methods

		internal static byte[] GenerateBytes(UserData userData)
		{
			byte[] userDataBytes = GenParse_UserData_Report.GenerateBytes(userData, NrOfBytes, UserData.UserData02StatusChangeReport2Confirm);
			return userDataBytes;
		}

		internal static bool ParseBytes(byte[] userDataBytes, out UserData userData02, out int consumedBytes)
		{
			// set default values
			userData02 = null;
			consumedBytes = 0;

			byte device;
			byte address;
			byte addressAddOn;
			eAddressExtension_1 addressExtension;
			ReportType_Base reportTypeBase;
			bool bRetVal = GenParse_UserData_Report.ParseBytes(userDataBytes, NrOfBytes, UserData.UserData02StatusChangeReport2Confirm,
						out device, out address, out addressAddOn, out addressExtension, out reportTypeBase);
			if (bRetVal)
			{
				userData02 = new UserData_02_StatusChangeReport2Confirm(device, address, addressAddOn, addressExtension, reportTypeBase);
				consumedBytes = NrOfBytes;
				return true;
			}
			
			// TODO handle error (not enough bytes)
			return false;
		}

		#endregion internal methods
	}
}
